package com.ykdl.member.kid.beans;

import java.io.Serializable;
import java.text.DecimalFormat;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ykdl.member.kid.adapters.DebateBean;

import net.wxxr.http.interfaces.IJsonParser;

public class ProductBean implements Serializable,IJsonParser{

	/**
	 * 
	 * ---------门店自营商品
	 *  {
            "status": 0,
            "product_type": 1, #商品类型 1:门店自营商品,2:分销商品
            "product_id": 2,
            "name": "商品1",
            "is_debate": true,
            "created_time": 1430363784,
            "list_pic": {
                "url": "http://imgs.ykdllmyr.com/fxs/2015/3/23/qqZ42isga6XF4HYWQJYKe3.jpeg",
                "width": 750,
                "file_id": 100386,
                "height": 588
            },
            "price": 20,
            "debate": {
                "debate_begin_time": 1427188230,
                "debate_end_time": 1431889500,
                "debate_price": 2,
                "debate_info": "折扣方式"
            },
            "store_id": 100100130
        },
        -------分销商品
        "status": 0,#商品状态 0:上架,1:下架,客户端无需判断商品是否上架
            "product_type": 2, #商品类型 1:门店自营商品,2:分销商品
            "product_id": 103,#商品唯一标识
            "price": 1,#商品单价
            "commission": 1,#商品佣金
            "created_time": 1437397840,#商品创建时间,时间戳
            "list_pic": {#商品列表图
                "url": "http://imgs.ykdllmyr.com/fxs/2015/7/20/C5FZsQLqfMtupfwna8PPJb.jpeg",
                "width": 1170,
                "file_id": 100101873,
                "height": 500
         },
            
	 */
	private static final long serialVersionUID = -5324737804743610958L;
	private int status;
	private int product_type;
	private String product_id;
	private FileBean list_pic;
	private String price;
	private boolean is_debate;
	private DebateBean debate;
	private String store_id;
	private String name;
	private String content;
	public String getContent() {
		return content;
	}
	public String getName() {
		return name;
	}
	public int getStatus() {
		return status;
	}
	public String getProduct_id() {
		return product_id;
	}
	public FileBean getList_pic() {
		return list_pic;
	}
	public String getPrice() {
		double float_price =Double.parseDouble(price);
		DecimalFormat decimalFormat=new DecimalFormat("##0.00");//构造方法的字符格式这里如果小数不足2位,会以0补足.
		String p=decimalFormat.format(float_price);//format 返回的是字符串
		return p;
	}
	public boolean isIs_debate() {
		return is_debate;
	}
	public DebateBean getDebate() {
		return debate;
	}
	public String getStore_id() {
		return store_id;
	}
	@Override
	public IJsonParser parse(String json) throws Exception {
		// TODO Auto-generated method stub
		Gson   gson = null;
		if(null != json){
			GsonBuilder b = new GsonBuilder();
			gson  = b.create();
			return gson.fromJson(json, ProductBean.class);
		}
		return null;
	}
	public int getProduct_type() {
		return product_type;
	}

}
